#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string>
#include <vector>


int processnum=5;

class channel
{
public:
  channel(int cmdfd,int slaverid,const std::string &processname)
  :_cmdfd(cmdfd),_slaverid(slaverid),_processname(processname)
  {}
public:
  int _cmdfd;
  pid_t _slaverid;
  std::string _processname;
};

int main()
{
  std::vector<channel> channels;
  for(int i=0;i<processnum;i++)
  {
    int pipefd[2];
    int n=pipe(pipefd);
    assert(!n);
    (void)n;
    pid_t id=fork();
    if(id==0)
    {
      close(pipefd[1]);
      slaver();
      exit(0);
    }
    close(pipefd[0]);
    
    std::string name="process-" + std::to_string(i);
    channels.push_back(channels[1],id,name);
  }
}
